import multiprocessing

from common.appium_server import appium_start
from common import logger

def multi_appium_start(num):
    appium_process = []
    logger.info(num)
    for i in range(num):
        host = '127.0.0.1'
        port = 4723 + 2 * i
        appium = multiprocessing.Process(target=appium_start, args=(host, port))  # 多进程同时并发执行
        appium_process.append(appium)
    logger.info("完成1")
    for appium in appium_process:
        appium.start()
    logger.info("完成2")
    for appium in appium_process:
        appium.join()  # 主进程等待子进程全部结束后才结束
    logger.info("完成3")

if __name__ == '__main__':
    multi_appium_start(3)
